import React from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import * as orderActions from '../../actions/order'
import * as addressActions from '../../actions/address'

export function connectOrder(Component) {
	class WrapComp extends React.Component {
		render() {
			return (
				<div><Component {...this.props} /></div>
			);
		}
	}
	 const mapStateToProps = (state) => ({
   		order: {
   			isFetched: state.order.isFetched,
			orderData: state.order.orderData,
			isCreated: state.order.isCreated,
		    detailisFetched: state.order.detailisFetched,
		    orderDetail: state.order.orderDetail,
		    isPreviewed: state.order.isPreviewed,
		    orderPreview: state.order.orderPreview,
   		},
   		address: {
   			addressData: state.address.addressData,
			isFetched: state.address.isFetched
   		}
  	});
  	const mapDispatchToProps = (dispatch) => ({
		orderActions: bindActionCreators(orderActions, dispatch),
		addressActions: bindActionCreators(addressActions, dispatch)
  	});
	return connect(mapStateToProps, mapDispatchToProps)(WrapComp);
}